﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace PengSW_SplitablePanel
{
    /// <summary>
    /// UserControl1.xaml 的交互逻辑
    /// </summary>
    public partial class SplitablePanel : UserControl
    {
        public SplitablePanel()
        {
            InitializeComponent();
        }

        private void OnHorizontalSplit_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            HorizontalSplit();
        }

        private void OnVerticalSplit_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            VerticalSplit();
        }

        public void HorizontalSplit()
        {
            gridContainer.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
            gridContainer.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) });
            gridContainer.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
            GridSplitter aSplitter = new GridSplitter() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, Height = 3 };
            gridContainer.Children.Add(aSplitter);
            Grid.SetRow(aSplitter, 1);
        }

        public void VerticalSplit()
        {

        }
    }
}
